﻿using DSSDataServiceGenerator.Commands;
using DSSDataServiceGenerator.Model;
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Input;

namespace DSSDataServiceGenerator.ViewModel
{
    public class ConnectionViewModel
    {
        public ConnectionViewModel()
            : base()
        { }

        public IConnection SelectedConnection { get; set; }

        private ICommand _ConnectCommand = null;
        public ICommand ConnectCommand
        {
            get
            {
                if (this._ConnectCommand == null)

                    this._ConnectCommand = new ModelCommand (
                        (object parameter) =>
                        {
                            return this.SelectedConnection != null;
                        },
                        (object parameter) =>
                        {
                            Window w = parameter as Window;

                            if (w != null)
                            { 
                                w.DialogResult = true;

                                w.Close();
                            }
                        }
                    );

                return this._ConnectCommand;
            }
        }
    }
}
